package com.gexin.model.activity;

import com.gexin.common.utils.SQLUtils;
import com.gexin.model.activity.base.BaseCashback;
import com.jfinal.plugin.activerecord.Page;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 业务名称:  t_cashback() 
 */
@SuppressWarnings("serial")
public class Cashback extends BaseCashback<Cashback> {
	public static final Cashback dao = new Cashback();

	public List<Cashback> findCashbackListByItemId(String itemId){
//		dao.fi
		SQLUtils sql = new SQLUtils("select * from t_cashback where 1=1 ");
		if(null!=itemId){
			sql.whereEquals("order_item_id",itemId);
		}
		return dao.find(sql.toString());
	}

	public Page<Cashback> getCashbackById(String productId, Integer startPage, Integer pageSize){
		SQLUtils sqlUtils = new SQLUtils(" from t_cashback where 1=1");
		if(null!=productId){
			sqlUtils.whereEquals("product_id",productId);
		}
		Page<Cashback> paginate = dao.paginate(startPage, pageSize, "select *",sqlUtils.toString());
		return paginate;
	}


	public String test(String id){
		SQLUtils sqlUtils = new SQLUtils(" from t_cashback where 1=1");
		if(null!=id){
			sqlUtils.whereEquals("item_id",id);
		}
		sqlUtils.toString();
		return null;
	}



	public void setItemIdAndBalanceAndSum(String id, String itemId, BigDecimal leftoverBalance, BigDecimal currentBalanceSum, Date date) {
		super.setId(id);
		super.setOrderItemId(itemId);
		super.setCashbackBalance(leftoverBalance);
		super.setCashbackBalanceSum(currentBalanceSum);
		super.setCreateTime(date);
	}
}
